#include <REGX52.H>

void delay_ms(unsigned int ms)
{
    unsigned int i, j;
    for (i = 0; i < ms; i++)
    {
        for (j = 0; j < 123; j++)
            ;
    }
}

void main()
{
    unsigned char i;
    // 0000 0001
    unsigned char temp = 0x01;
    // 全部置为0，熄灭
    P2 = 0x00;
    while (1)
    {

        for (i = 0; i < 8; i++)
        {
            P2 = temp;
            delay_ms(200);
            // temp = temp << 1;
            temp <<= 1;
        }
        temp = 0x80;

        for (i = 0; i < 8; i++)
        {
            P2 = temp;
            delay_ms(200);
            temp >>= 1;
        }
        temp = 0x01;
    }

    // 1000 0000  = 0x80
}